package d2_com.itheima.io;

import java.io.*;

/**
 * 字节缓冲流
 */
public class Test4 {
    public static void main(String[] args) {
        /**
         * 字节缓冲输入流 和 字节缓冲输出流
         */
        try (
                InputStream fo = new FileInputStream("oop-app6\\6.txt");
                ///1、定义一个字节缓冲输入流包装原始的字节输入流
                InputStream fos = new BufferedInputStream(fo);
                OutputStream fi = new FileOutputStream("oop-app6\\7.txt");
                //2、定义一个字节缓冲输出流包装原始的字节输出流
                OutputStream fis = new BufferedOutputStream(fi)
        ) {
            byte[] buffer = new byte[1024];
            int len;
            while ((len = fos.read(buffer)) != -1) {
                fis.write(buffer,0,len);
            }
            System.out.println("复制成功~");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
